using System;
using System.Text;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Data;

namespace CatalogManagerUnitTests
{
    /// <summary>
    /// While writing unitTests we we use the AAA principal
    /// 
    /// for a referance please check:
    /// http://www.lostechies.com/blogs/jimmy_bogard/archive/2008/07/24/arrange-act-assert-and-bdd-specifications.aspx
    /// </summary>
    [TestClass]
    public class ListEntities
    {
        private CatalogManagerDAL.ListEntities DAL_ListEntities = null; 

        public ListEntities()
        {
            DAL_ListEntities = new CatalogManagerDAL.ListEntities();
        }

        #region Additional test attributes
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test 
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion

        [TestMethod]
        public void ListProductDefinitions_ReturnsAtLeastOneEntity()
        {
            // arrange: DAL_ListEntities class is initialized in constructor.

            // act
            DataSet resultSet = DAL_ListEntities.ListProductDefinitions();
            
            // assert
            Assert.IsTrue(resultSet.Tables.Count>0, "No table exists");
            Assert.IsTrue(resultSet.Tables[0].Rows.Count >0, "No row exists in the table");
        }

        [TestMethod]
        public void ListProductDefinitionProperties_ReturnsAtLeastOneEntity()
        {
            // arrange: DAL_ListEntities class is initialized in constructor.

            // act
            DataTable resultTable = DAL_ListEntities.ListSingleProductDefinitionsProperties("Film");

            // assert
            Assert.IsTrue(resultTable  != null, "No table exists");
            Assert.IsTrue(resultTable.Rows.Count > 0, "No row exists in the table");
        }

        [TestMethod]
        public void ListSinglePropertysAttributes()
        {
            // arrange: DAL_ListEntities class is initialized in constructor.

            // act
            DataRow resultRow = DAL_ListEntities.GetProductDefinitionPropertyAttributes("PropertyName='Desi'");

            // assert
            Assert.IsTrue(resultRow != null, "result row is null");
            Assert.IsTrue(resultRow[0] != null, "result row first cell value is null");
        }

        [TestMethod]
        public void ListCatalogs_ReturnsAtLeastOneEntity()
        {
            // arrange: DAL_ListEntities class is initialized in constructor.

            // act
            DataTable resultTable = DAL_ListEntities.ListCatalogs();

            // assert
            Assert.IsTrue(resultTable != null, "No table exists");
            Assert.IsTrue(resultTable.Rows.Count > 0, "No row exists in the table");
        }

        [TestMethod]
        public void ListCategories_ReturnsAtLeastOneEntity()
        {
            // arrange: DAL_ListEntities class is initialized in constructor.

            // act
            DataTable resultTable = DAL_ListEntities.ListCategories("Telefon", null);

            // assert
            Assert.IsTrue(resultTable != null, "No table exists");
            Assert.IsTrue(resultTable.Rows.Count > 0, "No row exists in the table");
        }

        [TestMethod]
        public void ListCategorysCategories_ReturnsAtLeastOneEntity()
        {
            // arrange: DAL_ListEntities class is initialized in constructor.

            // act
            DataTable resultTable = DAL_ListEntities.ListCategories("Telefon", "kontorler(44000000)");

            // assert
            Assert.IsTrue(resultTable != null, "No table exists");
            Assert.IsTrue(resultTable.Rows.Count > 0, "No row exists in the table");
        }
    }
}
